home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Texteditors / Origami / bindings / viori.keys < prev   
Text File  |  1996-09-26  |  13KB  |  529 lines

  1.  
  2. {{{  sets
  3. ( defset word-char     ( alpha digit "_ ))
  4. (defset close-fence ( "} "] ") ))
  5. (defset open-fence  ( "{ "[ "( ))
  6. (defset fence       ( open-fence close-fence ))
  7. }}}
  8. {{{  aliases
  9. ( alias space ( "  ) )
  10. @if-using not( ATARI )
  11.    {{{  terminal sun
  12.    ( terminal ( sun )
  13.       ( alias backspace ( C-H ) )
  14.       ( alias delete ( C-? ) )
  15.       ( alias tab ( C-I ) )
  16.       ( alias down ( C-[ "[ "B ) )
  17.       ( alias left ( C-[ "[ "D ) )
  18.       ( alias right ( C-[ "[ "C ) )
  19.       ( alias up ( C-[ "[ "A ) )
  20.       ( alias f1 ( C-[ "[ "2 "2 "4 "z ) )
  21.       ( alias f2 ( C-[ "[ "2 "2 "5 "z ) )
  22.       ( alias f3 ( C-[ "[ "2 "2 "6 "z ) )
  23.       ( alias f4 ( C-[ "[ "2 "2 "7 "z ) )
  24.       ( alias f5 ( C-[ "[ "2 "2 "8 "z ) )
  25.       ( alias f6 ( C-[ "[ "2 "2 "9 "z ) )
  26.       ( alias f7 ( C-[ "[ "2 "3 "0 "z ) )
  27.       ( alias f8 ( C-[ "[ "2 "3 "1 "z ) )
  28.       ( alias f9 ( C-[ "[ "2 "3 "2 "z ) )
  29.    )
  30.    }}}
  31.    {{{  terminal SUN
  32.    ( terminal ( SUN )
  33.       ( alias backspace ( C-H ) )
  34.       ( alias delete ( C-? ) )
  35.       ( alias tab ( C-I ) )
  36.       ( alias f1 ( C-[ "[ "2 "2 "4 "z ) )
  37.       ( alias f2 ( C-[ "[ "2 "2 "5 "z ) )
  38.       ( alias f3 ( C-[ "[ "2 "2 "6 "z ) )
  39.       ( alias f4 ( C-[ "[ "2 "2 "7 "z ) )
  40.       ( alias R1 ( C-[ "[ "2 "0 "8 "z ) )
  41.       ( alias R2 ( C-[ "[ "2 "0 "9 "z ) )
  42.       ( alias R3 ( C-[ "[ "2 "1 "0 "z ) )
  43.       ( alias R4 ( C-[ "[ "2 "1 "1 "z ) )
  44.       ( alias R5 ( C-[ "[ "2 "1 "2 "z ) )
  45.       ( alias R6 ( C-[ "[ "2 "1 "3 "z ) )
  46.       ( alias R7 ( C-[ "[ "2 "1 "4 "z ) )
  47.       ( alias R8 ( C-[ "[ "2 "1 "5 "z ) )
  48.       ( alias R9 ( C-[ "[ "2 "1 "6 "z ) )
  49.       ( alias R10 ( C-[ "[ "2 "1 "7 "z ) )
  50.       ( alias R11 ( C-[ "[ "2 "1 "8 "z ) )
  51.       ( alias R12 ( C-[ "[ "2 "1 "9 "z ) )
  52.       ( alias R13 ( C-[ "[ "2 "2 "0 "z ) )
  53.       ( alias R14 ( C-[ "[ "2 "2 "1 "z ) )
  54.       ( alias R15 ( C-[ "[ "2 "2 "2 "z ) )
  55.       ( alias up ( C-[ "[ "A ) )
  56.       ( alias left ( C-[ "[ "D ) )
  57.       ( alias right ( C-[ "[ "C ) )
  58.       ( alias down ( C-[ "[ "B ) )
  59.    )
  60.    }}}
  61.    {{{  terminal PC
  62.    ( terminal ( PC )
  63.       @if-using not($ext)
  64.          ( alias ext ( C-@ ) )
  65.       @fi
  66.       ( alias backspace ( C-H ) )
  67.       ( alias delete ( $ext "S ) )
  68.       ( alias tab ( C-I ) )
  69.       ( alias dos-left ( $ext "K ) )
  70.       ( alias dos-right ( $ext "M ) )
  71.       ( alias dos-up ( $ext "H ) )
  72.       ( alias dos-down ( $ext "P ) )
  73.       ( alias dos-prev-page ( $ext "I ) )
  74.       ( alias dos-next-page ( $ext "Q ) )
  75.       ( alias dos-home ( $ext "G ) )
  76.       ( alias dos-end ( $ext "O ) )
  77.       ( alias dos-ins ( $ext "R ) )
  78.    )
  79.    }}}
  80.    {{{  terminal xterm
  81.    ( terminal ( xterm )
  82.       ( alias backspace ( C-H ) )
  83.       ( alias delete ( C-? ) )
  84.       ( alias tab ( C-I ) )
  85.       ( alias down ( C-[ "O "B ) )
  86.       ( alias left ( C-[ "O "D ) )
  87.       ( alias right ( C-[ "O "C ) )
  88.       ( alias up ( C-[ "O "A ) )
  89.       ( alias f1 ( C-[ "[ "1 "1 "~ ) )
  90.       ( alias f2 ( C-[ "[ "1 "2 "~ ) )
  91.       ( alias f3 ( C-[ "[ "1 "3 "~ ) )
  92.       ( alias f4 ( C-[ "[ "1 "4 "~ ) )
  93.    )
  94.    }}}
  95.    {{{  terminal vt100
  96.    ( terminal ( vt100 )
  97.       ( alias backspace ( C-H ) )
  98.       ( alias delete ( C-? ) )
  99.       ( alias tab ( C-I ) )
  100.       ( alias down ( C-[ "O "B ) )
  101.       ( alias left ( C-[ "O "D ) )
  102.       ( alias right ( C-[ "O "C ) )
  103.       ( alias up ( C-[ "O "A ) )
  104.       ( alias f1 ( C-[ "O "P ) )
  105.       ( alias f2 ( C-[ "O "Q ) )
  106.       ( alias f3 ( C-[ "O "R ) )
  107.       ( alias f4 ( C-[ "O "S ) )
  108.    )
  109.    }}}
  110.    {{{  terminal mgr
  111.    ( terminal ( mgr )
  112.       ( alias backspace ( C-H ) )
  113.       ( alias delete ( C-? ) )
  114.       ( alias tab ( C-I ) )
  115.       ( alias down ( C-[ "[ "B ) )
  116.       ( alias left ( C-[ "[ "D ) )
  117.       ( alias right ( C-[ "[ "C ) )
  118.       ( alias up ( C-[ "[ "A ) )
  119.       ( alias f1 ( C-[ "[ "2 "2 "4 "z ) )
  120.       ( alias f2 ( C-[ "[ "2 "2 "5 "z ) )
  121.       ( alias f3 ( C-[ "[ "2 "2 "6 "z ) )
  122.       ( alias f4 ( C-[ "[ "2 "2 "7 "z ) )
  123.       ( alias f5 ( C-[ "[ "2 "2 "8 "z ) )
  124.       ( alias f6 ( C-[ "[ "2 "2 "9 "z ) )
  125.       ( alias f7 ( C-[ "[ "2 "3 "0 "z ) )
  126.       ( alias f8 ( C-[ "[ "2 "3 "1 "z ) )
  127.       ( alias f9 ( C-[ "[ "2 "3 "2 "z ) )
  128.    )
  129.    }}}
  130. @fi
  131. @if-using ( ATARI )
  132.    {{{  st aliases
  133.    {{{F st-termalias
  134.    :::F st-termalias
  135.    }}}
  136.    ( alias R1 ( $KP_openbr ))
  137.    ( alias R2 ( $KP_closebr ))
  138.    ( alias R3 ( $KP_slash ))
  139.    ( alias R4 ( $KP_7 ))
  140.    ( alias R5 ( $KP_8 ))
  141.    ( alias R6 ( $KP_9 ))
  142.    ( alias R7 ( $KP_4 ))
  143.    ( alias R8 ( $KP_5 ))
  144.    ( alias R9 ( $KP_6 ))
  145.    ( alias R10 ( $KP_1 ))
  146.    ( alias R11 ( $KP_2 ))
  147.    ( alias R12 ( $KP_3 ))
  148.    ( alias R13 ( $KP_0 ))
  149.    ( alias R14 ( $KP_point ))
  150.    ( alias R15 ( $KP_enter ))
  151.    }}}
  152. @fi
  153. {{{  default-pseudo-fx
  154. ( alias EF1 ( $esc "F "1 ) )
  155. ( alias EF2 ( $esc "F "2 ) )
  156. ( alias EF3 ( $esc "F "3 ) )
  157. ( alias EF4 ( $esc "F "4 ) )
  158. }}}
  159. }}}
  160. {{{  forward
  161. (forward go-line)
  162. (forward enter-command-mode)
  163. }}}
  164. {{{  variables
  165. (defvar
  166.  (
  167.   go-line-arg;   Argument for go-line macro
  168.   matching;      matching mode? if non zero then the return address in case of an abort
  169.   modec;         current mode
  170.   starting-up;   is this the first time that read-new-file macro has been called?
  171.   still-reading;
  172.   blx;
  173.   want-newline;  to keep ex mode happy
  174.   tc;            target character for tTFf and r
  175.   diffx;
  176.   diffy;          delete line or fold?
  177.   isactive;       delete, fold indent or which other function
  178.   tot;            vi prefix totaliser.
  179.   extended;       extended or normal mode
  180.   wrap;           wrap mode or normal mode
  181.   tabx;           position on line for tabin or tabout
  182.   stop-at-eol;    FfTt~ stops at eol or continues...
  183.   fast-gotol;     Use goto or go line?
  184.   stepping;       stepping?
  185.   read-tab-width; new tab width
  186.   hard-tab;       internal tab width
  187.   old-mode;       mode to goto after leaving paramter mode.
  188.   mo;             temp to determine old mode in exit-parameter-mode
  189.   mode-temp;               temp var
  190.   command;
  191.   mc;             mark character counter
  192.   mtemp;          temporary var vor gotos
  193.  )
  194. )
  195. (defvar 26
  196.  ( mx;             x coordinate of the mark
  197.    my;             hashed (mark) y coordinate of the mark
  198.  )
  199. )
  200. }}}
  201. {{{  global bindings
  202.     {{{  @uses
  203.     @use (SCR-OFF mouse  FE-G-T-BUFF)
  204.     {{{  dont read this yet...
  205.     ; QUICHE means cursor keys in insert mode and double escape for command mode
  206.     ; insert mode is the default at startup
  207.     ; if QUICHE is not defined, then real user vi is set up
  208.     ; keyboard aliases are ignored if possible and only one escape, or a tab is needed.
  209.     ; command mode is the default startup.
  210.     }}}
  211.     }}}
  212.     (defbinding ViOri-0.a)
  213.     (keybind abort (C-C))
  214.  
  215.     (defmodes comrepmv-mode insert-mode parameter-mode ex-mode direct-mode resize-mode)
  216.  
  217.     {{{  internal mode identifiers
  218.     ; 0  command mode
  219.     ; 1  motion mode
  220.     ; 2  insert mode
  221.     ; 3  parameter mode
  222.     }}}
  223.     {{{  mode strings
  224.     ;these strings are for novice mode or for debugging use.
  225.     (defmodestring com "Command "Com)
  226.     (defmodestring ins "Insert "Ins)
  227.     (defmodestring prm "parameter "Prm)
  228.     (defmodestring mot "Motion "Mot)
  229.     (defmodestring ex "Ex-mode "Ex)
  230.     (defmodestring rep "Repeat "Rep)
  231.     }}}
  232.     {{{  abort macro
  233.     (deffun abort-tidy
  234.      ( if >(matching 0)
  235.       ( set go-line-arg matching
  236.         go-line
  237.       )
  238.       fi
  239.       enter-command-mode
  240.      )
  241.     )
  242.     }}}
  243.     {{{  no-modes
  244.     (defmac no-modes
  245.       ( reset-user-mode com
  246.         reset-user-mode ins
  247.         reset-user-mode prm
  248.         reset-user-mode mot
  249.         reset-user-mode ex
  250.       )
  251.      )
  252.     }}}
  253.     {{{  mode entry macros
  254.  
  255.        {{{  enter-command-mode
  256.        (deffun enter-command-mode
  257.         ( add-mode-view
  258.           no-modes
  259.           set-user-mode com
  260.           comrepmv-mode
  261.           set modec 0
  262.           set old-mode 0
  263.         )
  264.        )
  265.        }}}
  266.        {{{  enter-insert-mode
  267.        (deffun enter-insert-mode
  268.         ( set old-mode modec
  269.           set modec 2
  270.           delete-mode-view
  271.           no-modes
  272.           set-user-mode ins
  273.           insert-mode
  274.         )
  275.        )
  276.        }}}
  277.        {{{  enter-parameter-mode
  278.        (deffun enter-parameter-mode
  279.         ( set old-mode modec
  280.           set modec 3
  281.           no-modes
  282.           set-user-mode prm
  283.           parameter-mode
  284.         )
  285.        )
  286.        }}}
  287.        {{{  enter-motion-mode
  288.        (deffun enter-motion-mode
  289.         (add-mode-view
  290.          no-modes
  291.          set-user-mode mot
  292.          set modec 1
  293.          comrepmv-mode
  294.         )
  295.        )
  296.        }}}
  297.        {{{  enter-ex-mode
  298.        (deffun enter-ex-mode
  299.         ( delete-mode-view
  300.           no-modes
  301.           set-user-mode ex
  302.           ex-mode
  303.         )
  304.        )
  305.        }}}
  306.        {{{  enter-resize-mode
  307.        (deffun enter-resize-mode
  308.         ( resize-mode)
  309.        )
  310.        }}}
  311.     }}}
  312.     {{{  mode exit macros
  313.        {{{  exit-parameter-mode
  314.        (deffun exit-parameter-mode
  315.          ( newline-and-indent
  316.            set modec old-mode
  317.            comrepmv-mode
  318.          )
  319.        )
  320.        }}}
  321.        {{{  exit-ex-mode
  322.        (deffun exit-ex-mode
  323.         ( if =(still-reading 0)
  324.           ( ; there is no point in calling ex mode from motion mode ?
  325.             enter-command-mode
  326.  
  327.           )
  328.           fi
  329.         )
  330.        )
  331.        }}}
  332.     }}}
  333.     {{{  automatic macros
  334.     {{{  enter-prompt-fix
  335.     ;deffun enter-prompt-fix
  336.      ;E
  337.     }}}
  338.     {{{  exit-prompt-fix
  339.     }}}
  340.     {{{  read-newfile-macro
  341.     (deffun vi-read-newfile-macro
  342.      ( add-mode-position
  343.        add-mode-autosave "10 newline-and-indent
  344.        enter-command-mode
  345.      )
  346.     )
  347.     }}}
  348.     ;(auto-save-macro)
  349.  
  350.      (read-newfile-macro vi-read-newfile-macro)
  351.     ;(change-buffer-macro name)
  352.      (begin-prompt-macro  enter-parameter-mode )
  353.      (end-prompt-macro exit-parameter-mode)
  354.  
  355.      (key-not-bound-macro enter-command-mode)
  356.     ;(view-macro name)
  357.  
  358.      (abort-macro abort-tidy)
  359.     ;(key-not-bound-macro name)
  360.     ;(sigquit-macro name)
  361.     ;(sigusr1-macro name)
  362.     ;(sigusr2-macro name)
  363.  
  364.  
  365.     {{{  pascal
  366.     (defmark pascal
  367.       (  ("< "< "<)
  368.         (". ". ".)
  369.         (": ": ":)
  370.         ("> "> ">)
  371.       )
  372.     )
  373.     (defmark script (("# "# "@)
  374.                      (". ". ".)
  375.                      ("# "# ":)
  376.                      ("# "# "$)
  377.                     )
  378.     )
  379.  
  380.     }}}
  381.     }}}
  382.  
  383. }}}
  384. {{{  external macros and functions
  385. @lib exit
  386. @lib vi-fun/stdmac
  387. @use (REGIONS-INDENT) @lib regions @use not(REGIONS-INDENT)
  388. @lib xsel
  389. @lib mt-fold
  390. @lib fillpara
  391. @lib buff-chg
  392. @lib buff-size
  393. @lib tags-mac
  394. @lib np-file
  395. {{{  set fill column
  396. ( deffun vi-set-fill-column
  397.   ( direct-mode
  398.     set-fill-column
  399.     comrepmv-mode
  400.   )
  401. )
  402.  
  403. }}}
  404. {{{  space to cope with wrap mode
  405. ( defmac space ( wrap-word ) )
  406. }}}
  407. {{{  functions to hack ex and parameter modes, and arguments
  408.  
  409. (deffun newline-or-exit-mode
  410.  ( if =(want-newline 0)
  411.      ( enter-command-mode )
  412.    else
  413.      (newline-and-indent)
  414.    fi
  415.  )
  416. )
  417.  
  418. }}}
  419. {{{  macro to enter command mode from insert mode
  420. (deffun enter-command-from-insert
  421.  ( set mode-temp -(modec 2)
  422.    if =(mode-temp 0)
  423.     ( ; then commmand mode
  424.       enter-command-mode
  425.     )
  426.    fi
  427.  )
  428. )
  429. }}}
  430.  
  431. {{{  vi-fun/viwrdmac as there are a few slight differences.
  432. {{{  blank-left              skip the whitespace left to next word
  433. (deffun blank-left (
  434.   while not(test-char-set word-char)
  435.    {{{  back or line up
  436.    ( if pre (set blx -(store-pos 1)) =(blx 0)
  437.       ( word-line-up )
  438.      else
  439.       ( backward-character )
  440.      fi
  441.    )
  442.    }}}
  443. ))
  444. }}}
  445. {{{  blank-right             skip the whitespace right to next word
  446. (deffun blank-right (
  447.   while not(test-char-set word-char)
  448.    {{{  right or down
  449.    ( if test-end-line
  450.        ( word-line-down )
  451.      else
  452.        ( forward-character )
  453.      fi
  454.    )
  455.    }}}
  456. ))
  457. }}}
  458. (deffun vi-forward-word (
  459.   enter-command-from-insert
  460.   {{{  end word or next-line
  461.   if test-end-line
  462.     ( word-line-down )
  463.   else
  464.     ( end-word )
  465.   fi
  466.   }}}
  467.   blank-right
  468. ))
  469.  (deffun vi-backward-word (
  470.   enter-command-from-insert
  471.    {{{  one step left
  472.    if test-begin-line
  473.      ( word-line-up )
  474.    else
  475.      ( backward-character )
  476.    fi
  477.    }}}
  478.    blank-left
  479.    start-word
  480.  ))
  481. (deffun vi-forward-WORD (
  482.   enter-command-from-insert
  483.   {{{  end word or next-line
  484.   if test-end-line
  485.     ( word-line-down )
  486.   else
  487.     ( end-word )
  488.   fi
  489.   }}}
  490.   blank-right
  491. ))
  492. (deffun vi-backward-WORD (
  493.   enter-command-from-insert
  494.   {{{  one step left
  495.   if test-begin-line
  496.     ( word-line-up )
  497.   else
  498.     ( backward-character )
  499.   fi
  500.   }}}
  501.   blank-left
  502.   start-word
  503. ))
  504. }}}
  505. {{{  vi-append-to-previous-line
  506. (deffun vi-append-to-previous-line (
  507.   enter-command-from-insert
  508.   delete-mode-view
  509.   if not(test-text) (failed) fi
  510.   end-of-line
  511.   delete-character
  512.   delspaces
  513.   add-mode-view
  514. ))
  515.  
  516. }}}
  517. }}}
  518.  
  519. {{{  unbind remaining keys
  520. (mode ex-mode ( keybind - ( * ) ) )
  521. (mode comrepmv-mode ( keybind - ( * ) ) )
  522. }}}
  523. @lib vi-fun/functions
  524. @lib vi-fun/modes
  525.  
  526. @use ( ViOri-Reference-Card-REF )
  527. @lib vi-fun/ref.ocl
  528. @use not( ViOri-Reference-Card-REF )
  529.